<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title> - 修改页面</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link href="/static/admin/layui/css/layui.css" rel="stylesheet">
    <!--<link rel="shortcut icon" href="/favicon.ico">-->
    <link href="/static/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/static/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <link href="/static/admin/css/animate.css" rel="stylesheet">
    <link href="/static/admin/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="/static/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <style>
        .menuTitle{
            margin-top:10px;
            line-height: 35px;
            background:#cccccc;
            color:#000;
            padding-left:15px;

        }
    </style>


</head>

<body class="gray-bg">
    <div class="row wrapper border-bottom white-bg page-heading">
        <div class="col-sm-4">
            <h2>修改页面</h2>
            <ol class="breadcrumb">
                <li>
                    <a href="{:url('Index/admin')}">主页</a>
                </li>
                <li>
                    <strong>修改页面</strong>
                </li>
            </ol>
        </div>
    </div>
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-14">

                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>添加课程</h5>
                    </div>
                    <div class="ibox-content">
                        <form class="form-horizontal" >
                            <input type="hidden" id="ids" value="{$res.co_id}" class="form-control ids">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">课程：</label>
                                <div class="col-sm-4">
                                    <input type="text" placeholder="输入课程名称" id="username" value="{$res.co_name}" class="form-control">
                                </div>
                                <div class='col-sm-6'></div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">课程类型：</label>
                                <div class="col-sm-4">
                                    <select class="form-control m-b rid coursetype" name="rid" id="r_id">
                                        {foreach name="e" item="vo"}
                                        <option  {if condition="$res.ct_id eq $vo.ct_id"} selected="selected" {/if} value="{$vo.ct_id}" >{$vo.ct_name}</option>
                                        {/foreach}

                                    </select>
                                </div>
                                <div class="col-sm-6"></div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">课程价格：</label>
                                <div class="col-sm-4">
                                    <input type="text" placeholder="输入课程价格名称" id="price" value="{$res.co_money}" class="form-control">
                                </div>
                                <div class='col-sm-6'></div>
                            </div>


                            <div class="form-group">
                                <div class="col-sm-offset-2 col-sm-6">
                                    <input type="button"  value="保 存"  class="btn btn-sm btn-info" id="adds" />
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 全局js -->
    <script src="/static/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="/static/admin/js/bootstrap.min.js?v=3.3.6"></script>
    <!-- 自定义js -->
    <script src="/static/admin/js/content.js?v=1.0.0"></script>
    <script src="/static/admin/js/jquery.min.js"></script>
    <script src="/static/admin/layui/layui.js"></script>
    <!--icheck-->
    <script src="/static/admin/js/plugins/iCheck/icheck.min.js"></script>

    <script>
        /*
         * icheck
         */
        $('input[class^="menu"]').on('ifChanged', function(event){
            var className = $(this).attr("class");
            var pid = $(this).attr("pid");
            var menu = $(".menu"+pid);
            var preObj = $("#parmenu"+pid);
            var s = 0;
            for(i in menu){
                if(menu.eq(i).is(":checked")){
                    s++;
                }
            }
            if(s === 0){
                preObj.prop("checked",false);
            }else if(s >0){
                preObj.prop("checked",true);
            }
        });

        //单选和复选框
        $(document).ready(function () {
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });
        });
        //layui
        layui.use('upload', function(){ //独立版的layer无需执行这一句
            var $ = layui.jquery, layer = layui.layer,upload = layui.upload; //独立版的layer无需执行这一句
            var photo = "";
            //点击提交
            $("#adds").click(function(){
                $.post("{:url('Jiaowu/sav')}",{co_name:$("#username").val(),co_id:$(".ids").val(),ct_id:$(".coursetype").val(),co_money:$("#price").val()},function(data){

                    layer.msg(data.msg, {time: 2000}, function () {
                        
                           window.location.href = data.url;
                    });

                })

            });
            //普通图片上传
            var uploadInst = upload.render({
                elem: '#test1'
                ,url: "{:url('Admins/upload')}"
                ,before: function(obj){
                    //预读本地文件示例，不支持ie8
                    obj.preview(function(index, file, result){
                        $('#demo1').attr('src', result); //图片链接（base64）
                    });
                }
                ,done: function(res){
                    //如果上传失败
                    if(res.code == 0){
                        return layer.msg('上传失败');
                    }else if(res.code){
                        //上传成功
                        photo = res.photo;
                        return layer.msg('上传成功');
                    }
                }
                ,error: function(){
                    //演示失败状态，并实现重传
                    var demoText = $('#demoText');
                    demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                    demoText.find('.demo-reload').on('click', function(){
                        uploadInst.upload();
                    });
                }
            });
        });

    </script>
    
    

</body>

</html>
